// import com.alibaba.druid.sql.ast.*;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

#include "SQLShowQueryTaskStatement.h"
#include "../../visitor/SQLASTVisitor.h"
#include "../SQLLimit.h"

SQLShowQueryTaskStatement::SQLShowQueryTaskStatement()
{
}

// @Override
void SQLShowQueryTaskStatement::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLShowQueryTaskStatement)))
  {
    acceptChild(visitor, where);
    acceptChild(visitor, orderBy);
    acceptChild(visitor, limit);
    acceptChild(visitor, user);
  }
  visitor->endVisit(SharedObject(SQLShowQueryTaskStatement));
}

SQLExpr_ptr SQLShowQueryTaskStatement::getWhere()
{
  return where;
}

void SQLShowQueryTaskStatement::setWhere(SQLExpr_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLShowQueryTaskStatement));
  }
  this->where = x;
}

SQLExpr_ptr SQLShowQueryTaskStatement::getUser()
{
  return user;
}

SQLExpr_ptr SQLShowQueryTaskStatement::getFor()
{
  return user;
}

void SQLShowQueryTaskStatement::setUser(SQLExpr_ptr user)
{
  this->user = user;
}

SQLOrderBy_ptr SQLShowQueryTaskStatement::getOrderBy()
{
  return orderBy;
}

void SQLShowQueryTaskStatement::setOrderBy(SQLOrderBy_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLShowQueryTaskStatement));
  }
  this->orderBy = x;
}

SQLLimit_ptr SQLShowQueryTaskStatement::getLimit()
{
  return limit;
}

void SQLShowQueryTaskStatement::setLimit(SQLLimit_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLShowQueryTaskStatement));
  }
  this->limit = x;
}

// @Override
BOOL_ptr SQLShowQueryTaskStatement::replace(SQLExpr_ptr expr, SQLExpr_ptr target)
{
  if (where == expr)
  {
    setWhere(target);
    return BOOL::TRUE;
  }

  if (user == expr)
  {
    setUser(target);
    return BOOL::TRUE;
  }

  return BOOL::FALSE;
}

BOOL_ptr SQLShowQueryTaskStatement::isFull()
{
  return full;
}

void SQLShowQueryTaskStatement::setFull(BOOL_ptr full)
{
  this->full = full;
}
